﻿using System;
using System.Collections.Generic;
using System.Text;
using TarreOA.TarreOAModels;
using TarreOA.TarreOADAL;

namespace TarreOA.TarreOABLL
{
    public class UserFileCabinetUploadFiletbService
    {
        /// <summary>
        /// 保存上传文件信息
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="FilePath"></param>
        /// <param name="fileUploadTime"></param>
        /// <param name="fileCabinetId"></param>
        /// <returns></returns>
        public int saveUploadFileInfo(string fileName, string filePath, DateTime fileUploadTime, int fileCabinetId)
        {
            UserFileCabinetUploadFiletbDAO userFileCabinetUploadFiletbDAO = new UserFileCabinetUploadFiletbDAO();
            return userFileCabinetUploadFiletbDAO.saveUploadFile(fileName, filePath, fileUploadTime, fileCabinetId);
        }

        /// <summary>
        /// 根据所处记录编号查找记录的上传文件信息
        /// </summary>
        /// <param name="fcid"></param>
        /// <returns></returns>
        public List<UserFileCabinetUploadFile> findByFileCabinetId(int fcid)
        {
            UserFileCabinetUploadFiletbDAO userFileCabinetUploadFiletbDAO = new UserFileCabinetUploadFiletbDAO();
            return userFileCabinetUploadFiletbDAO.findByFileCabinetId(fcid);
        }

        /// <summary>
        /// 根据文件编号删除上传文件信息
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        public bool delAffixFileInfo(int fid)
        {
            bool state = false;
            UserFileCabinetUploadFiletbDAO userFileCabinetUploadFiletbDAO = new UserFileCabinetUploadFiletbDAO();
            if (userFileCabinetUploadFiletbDAO.delUploadFileByFileId(fid) == 1)
            {
                state = true;
            }
            return state;
        }

        /// <summary>
        /// 根据文件编号查找文件信息
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        public UserFileCabinetUploadFile findByFileId(int fid)
        {
            UserFileCabinetUploadFiletbDAO userFileCabinetUploadFiletbDAO = new UserFileCabinetUploadFiletbDAO();
            return userFileCabinetUploadFiletbDAO.findByFileId(fid);
        }
    }
}
